#include<iostream>
#include<cmath>
#include"ProblemA.h"
using namespace std;

double Function1(double x){
    return sin(x / 2) - 1;
}

double Function2(double x){
    return exp(x) - tan(x);
}

double Function3(double x){
    return x*x*x - 12*x*x + 3*x + 1;
}


int main(){

    double eps = 10e-7;

    cout << "Function1:" << endl;

    Secant zero1(0 , M_PI/2 , eps * 10e-7 , Function1);
    cout << "选取题给初始值x_0 = 0, x_1 = pi/2:";
    CheckPrint(zero1.solve(),  Function1);

    Secant zero1_(10 , 4 * M_PI , eps * 10e-7 , Function1);
    cout << "选取新的初始值x_0 = 10, x_1 = 4pi:";
    CheckPrint(zero1_.solve(),  Function1);


    cout << "Function2:" << endl;

    Secant zero2(1 , 1.4 , eps , Function2);
    cout << "选取题给初始值x_0 = 1, x_1 = 1.4:";
    CheckPrint(zero2.solve(), Function2);

    Secant zero2_(-3 , -3.4 , eps , Function2);
    cout << "选取新的初始值x_0 = -3, x_1 = -3.4:";
    CheckPrint(zero2_.solve(), Function2);


    cout << "Function3:" << endl;

    Secant zero3(0 , -0.5 , eps , Function3);
    cout << "选取题给初始值x_0 = 0, x_1 = -0.5:";
    CheckPrint(zero3.solve(), Function3);

    Secant zero3_(0.5 , 1 , eps , Function3);
    cout << "选取新的初始值x_0 = 0.5, x_1 = 1:";
    CheckPrint(zero3_.solve(), Function3);

    return 0;
}